package com.qdsg.ysg.doctor.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.qdsg.ysg.doctor.R;
import com.qdsg.ysg.doctor.util.UIConstants;

import jz.joyoung.robot.util.LogUtil;


public abstract class BaseHycActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        //Add a log to load the layout
        ActivityStack.getIns().push( this );

        initializeData();
        initializeComposition();
        LogUtil.i( UIConstants.DEMO_TAG, "Activity onCreate: " + getClass().getSimpleName() );
    }

    public abstract void initializeComposition();

    public abstract void initializeData();


    protected void initBackView(int resource) {
        View backView = findViewById( resource );
        if (null != backView) {
            backView.setOnClickListener( new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBack();
                }
            } );
        }
    }

    protected void onBack() {
        ActivityStack.getIns().popup( this );
        // onBackPressed();
    }

    @Override
    protected void onDestroy() {
        ActivityStack.getIns().popup( this );
        super.onDestroy();
    }

    public void showToast(int resId) {
        Toast.makeText( this, getString( resId ), Toast.LENGTH_SHORT ).show();
    }
}
